<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script type="text/javascript">
  var maxScrollLeftiFrame;

  setPrintTestResultsLazily();
  jsTestIsAsync = true;
  description("This test ensures that if an autoscroll starts from within a " +
    "scrollable div in an iframe, it does not propagate to its non-scrollable " +
    "document body. Furthermore, it tests that if the body has only one of " +
    "overflowX or overflowY set to hidden, the scrollable axis actually " +
    "scrolls. Note that this test is pertaining to crbug.com/531525.");

  function finishTest() {
    eventSender.mouseUp();
    var iframe = document.getElementById('partialScrolliFrame');
    var iframeDoc = iframe.contentDocument;
    // Because only overflowY:hidden is set, horizontal scroll should happen and
    // vertical scroll shouldn't.
    if (iframeDoc.scrollingElement.scrollTop == 0 && iframeDoc.scrollingElement.scrollLeft == maxScrollLeftiFrame) {
      testPassed("Document didn't scroll.");
    } else {
      testFailed("Document scrolled although overflow:hidden.");
    }
    document.getElementById('partialScrolliFrame').style.display = 'none';
    finishJSTest();
  }

  window.onload = function () {
    var iframe = document.getElementById('partialScrolliFrame');
    var iframeDoc = iframe.contentDocument;
    iframeDoc.body.style.overflowY = "hidden"
    maxScrollLeftiFrame = iframeDoc.scrollingElement.scrollWidth - iframe.contentWindow.innerWidth;

    var element = iframeDoc.getElementById('select');
    var x = iframe.offsetLeft + element.offsetLeft + 7;
    var y = iframe.offsetTop + element.offsetTop + 7;
    eventSender.dragMode = false;
    eventSender.mouseMoveTo(x, y);
    eventSender.mouseDown();
    eventSender.mouseMoveTo(x + 800, y);
    eventSender.mouseMoveTo(x + 800, y + 500);
    window.requestAnimationFrame(finishTest);
  }
</script>

<iframe id="partialScrolliFrame" src="resources/page-with-scrollable-div.html"></iframe>

